class Solution:
    def maxProfit(self, prices: list) -> int:
        if len(prices) == 0:
            return 0
        res = 0
        for i in range(1, len(prices)):
            if prices[i] > prices[i-1]:
                res += (prices[i] - prices[i-1])
        return res


a = Solution()
print(a.maxProfit([7, 1, 5, 3, 6, 4]))
print(a.maxProfit([7, 3, 5, 1, 6, 4]))
print(a.maxProfit([7, 3, 5, 6, 1, 4]))
print(a.maxProfit([7, 6, 4, 3, 1]))
print(a.maxProfit([]))
